package com.arron.java基础.this指针;

public class this指针 {
    public static void main(String[] args) {
        TestA aa1 = new TestA(10);
        TestA aa2 = new TestA(20);
        aa1.show();//aa1.show(aa1);指针
        aa2.show();//aa1.show(aa2);指针
    }
}

class TestA
{
    int i;
    public TestA(int i) {
        this.i = i;//this指针，通常参数名一样
    }
    //如何知道输出aa1的show还是aa2的show，本身隐藏的this指针传入地址
    //public void show1(A* this)//this代表的当前正在调用show方法人对象
    //{
    //    System.out.println("i=%d",(*this).i);
    //}
    public void show() {
        System.out.printf("i=%d\n", i);//也可以this.i
    }
}

